package test;

public class TryDemo4 {
    public static void main(String[] args) {
        try {
            testThree();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    public static void testOne() throws HotelAgeException {
        throw new HotelAgeException();
    }
    //异常链
    public static void testTwo() throws Exception {
        try {
            testOne();
        } catch (HotelAgeException e) {
            throw new Exception("我是新产生的异常1",e);//保留异常
        }
    }
    public static void testThree() throws Exception {
        try {
            testTwo();
        } catch (Exception e) {
            throw new Exception("我是新产生的异常2",e);//保留异常
        }
    }
}
